<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jq/jquery.3.3.1.min.js"></script>
</head>
<style>
    table{
        border-collapse: separate;
        border-spacing: 0;
        border-top: 1px solid lightgray;
        border-left: 1px solid lightgray;
    }
    td{
        border: 1px solid lightgray;
        border-top: none;
        border-left: none;
    }
    .title3:hover{
        color: #ff9979;
    }
</style>
<body>
<form action="#" method="post">
    <h1 style="color: #ffb241" align="center">请登录</h1>
    <table width="450" align="center" style="box-shadow: 0px 2px 12px rgba( 0,0,0,0.1);">
        <tr>
            <td colspan="2" bgcolor="#ffaf64">登录</td>
        </tr>
        <tr>
            <td>用户：</td>
            <td><input type="text" name="username" id="username"></td>
        </tr>
        <tr>
            <td>密码：</td>
            <td><input type="password" name="password" id="password"></td>
        </tr>
        <tr>
            <td><a href="regist.html" name="register" class="title3" style="text-decoration: none;">没有用户？请点此处注册</a></td>
            <td><button type="button" id="login">登录</button></td>
        </tr>
    </table>
</form>
<script>
    /*登录页面接口*/ /*http://192.168.104.64:8084/login.html*/
    $(function () {
        $('#login').click(function () {
            var username = document.getElementById("username").value;
            var password = document.getElementById("password").value;
            $.ajax({
                url:'http://192.168.104.64:9003/toLogin',
                type:'post',
                data:{username:username,password:password},
                dataType:'json',
                success:function (res) {
                    if(res.code=="membernull")
                        alert("不存在该用户！")
                    if(res.code=="pwderr"){
                        alert("密码错误！")
                    }else if(res.code=="right"){
                        alert("登陆成功！")
                        window.sessionStorage.setItem("memberid",res.token.memberid);
                        window.sessionStorage.setItem("username",res.token.username);
                        window.sessionStorage.setItem("password",res.token.password);
                        window.sessionStorage.setItem("nickname",res.token.nickname);
                        window.location.href="http://192.168.104.114:8080/seat.html";
                    }
                }
            })
        })
    })
</script>
</body>
</html>